package com.wuye.dao;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.wuye.entity.Users;
@Repository("usersDao")
public class UsersDaoImpl {
	@Resource
	private HibernateTemplate hibernateTemplate;
	@Resource
	private Tool tool;
	public void save(Users users){
		hibernateTemplate.save(users);
	}
	public void del(Users users){
		hibernateTemplate.delete(users);
	}
	public void update(Users users){
		hibernateTemplate.update(users);
	}
	public Map getlist( String[] titel,String hql,  int offset, int length){
		
		return tool.getJSON(titel,hql, offset, length);
	}
	public List<Users> getComboxList(){
		return hibernateTemplate.find("from Users u where u.beizhu !='admin'");
	}
	public Users getUsersByid(int id){
		return hibernateTemplate.get(Users.class, id);
	}
	public List getUsersByHql(String[] sz){
		return hibernateTemplate.find("from Users u where u.name=? and u.pwd=?", sz);
	}
	
	public int getCount(){
		return hibernateTemplate.find("from Users").size();
	}
	
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	public Tool getTool() {
		return tool;
	}
	public void setTool(Tool tool) {
		this.tool = tool;
	}
}
